#include <iostream>
#include <random>
#include <vector>
#include <cstring>
#include <cassert>
#include <chrono>

const int N = 2e5 + 5;
const int M = 75;

int n, m, q;
unsigned long long seed = std::chrono::steady_clock::now().time_since_epoch().count();
std::mt19937_64 rnd(seed);
int uni[N];
bool vis[N];
std::vector<std::pair<int, int>> adj[N];
unsigned long long w[N], d[N];
unsigned long long base[M];

inline int find(int x) {
	return x == uni[x] ? x : uni[x] = find(uni[x]);
}

inline void dfs(int u, int fa) {
	for(auto [v, e] : adj[u]) if(v != fa) {
		dfs(v, u);
		d[u] ^= d[v];
		w[e] = d[v];
	}
}

bool ins(unsigned long long x) {
	for(int i = 63; i >= 0; --i) {
		if(x >> i & 1) {
			if(!base[i]) {
				base[i] = x;
				return 1;
			} else {
				x ^= base[i];
			}
		}
	}
	assert(x == 0);
	return 0;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	
	std::freopen("graph.in", "r", stdin);
	std::freopen("graph.out", "w", stdout);
	
	std::cin >> n >> m;
	for(int i = 1; i <= n; ++i) uni[i] = i;
	for(int i = 1; i <= m; ++i) {
		int u, v; std::cin >> u >> v;
		if(find(u) != find(v)) {
			uni[find(u)] = find(v);
			adj[u].emplace_back(v, i);
			adj[v].emplace_back(u, i);
			vis[i] = 0;
		} else {
			unsigned long long x = rnd();
			w[i] = x;
			d[u] ^= x;
			d[v] ^= x;
		}
	}
	dfs(1, 0);
	std::cin >> q;
	while(q--) {
		int k; std::cin >> k;
		std::memset(base, 0, sizeof base);
		bool ok = 1;
		while(k--) {
			int e; std::cin >> e;
			ok &= ins(w[e]);
		}
		std::cout << (ok ? "YES" : "NO") << "\n";
	}
	std::cerr << seed << "\n";
	return 0;
}

